﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ASCalpuff.FileLayers
{
    public class PG0:Group
    {
        // Fields

        //输入参数

        //calmet.dat文件的数量

        //气象数据文件，inputfiles
        private List<string> m_METDAT = new List<string>();

        public List<string> METDAT
        {
            get { return m_METDAT; }
            set { m_METDAT = value; }
        }

        //isc3格式或扩展格式文件
        private string m_ISCDAT = "PROFILE.DAT";

        public string ISCDAT
        {
            get { return m_ISCDAT; }
            set { m_ISCDAT = value; }
        }

        //ausplume格式文件
        private string m_PLMDAT = "";

        public string PLMDAT
        {
            get { return m_PLMDAT; }
            set { m_PLMDAT = value; }
        }
        //CTDM廓线格式的气象数据文件
        private string m_PRFDAT = "PROFILE.DAT ";

        public string PRFDAT
        {
            get { return m_PRFDAT; }
            set { m_PRFDAT = value; }
        }

        //CTDM地面站格式的气象数据文件
        private string m_SFCDAT = "SURFACE.DAT";

        public string SFCDAT
        {
            get { return m_SFCDAT; }
            set { m_SFCDAT = value; }
        }

        //运行开始阶段模型读取的重启文件
        private string m_RSTARTB = "";

        public string RSTARTB
        {
            get { return m_RSTARTB; }
            set { m_RSTARTB = value; }
        }




        //puflst文件，输出文件

        private string m_PUFLST = "CALPUFF.lst";

        public string PUFLST
        {
            get { return m_PUFLST; }
            set { m_PUFLST = value; }
        }

        //浓度文件
        private string m_CONDAT = "CONC.DAT";

        public string CONDAT
        {
            get { return m_CONDAT; }
            set { m_CONDAT = value; }
        }

        //干沉降文件
        private string m_DFDAT = "DFLX.DAT";

        public string DFDAT
        {
            get { return m_DFDAT; }
            set { m_DFDAT = value; }
        }
        //湿沉降文件
        private string m_WFDAT = "WFLX.DAT";

        public string WFDAT
        {
            get { return m_WFDAT; }
            set { m_WFDAT = value; }
        }
        //相对湿度文件（用于计算可见性）
        private string m_VISDAT = "VISB.DAT";

        public string VISDAT
        {
            get { return m_VISDAT; }
            set { m_VISDAT = value; }
        }


        private string m_T2DDAT = "";

        public string T2DDAT
        {
            get { return m_T2DDAT; }
            set { m_T2DDAT = value; }
        }
        private string m_RHODAT = "";

        public string RHODAT
        {
            get { return m_RHODAT; }
            set { m_RHODAT = value; }
        }

        //模型运行中写入的模型重启文件
        private string m_RSTARTE = "";

        public string RSTARTE
        {
            get { return m_RSTARTE; }
            set { m_RSTARTE = value; }
        }


        //输入文件

        //可以任意变化的点源排放文件
        private string m_PTDAT = "";

        public string PTDAT
        {
            get { return m_PTDAT; }
            set { m_PTDAT = value; }
        }

        //任意变化体源排放文件

        private string m_VOLDAT = "";

        public string VOLDAT
        {
            get { return m_VOLDAT; }
            set { m_VOLDAT = value; }
        }

        //任意变化浮力面源
        private string m_ARDAT = "";

        public string ARDAT
        {
            get { return m_ARDAT; }
            set { m_ARDAT = value; }
        }
        //任意变化浮力线源
        private string m_LNDAT = "";

        public string LNDAT
        {
            get { return m_LNDAT; }
            set { m_LNDAT = value; }
        }
        //臭氧的小时监测浓度文件
        private string m_OZDAT = "OZONE.DAT";

        public string OZDAT
        {
            get { return m_OZDAT; }
            set { m_OZDAT = value; }
        }
        //自定义沉降速度文件
        private string m_VDDAT = "VD.DAT";

        public string VDDAT
        {
            get { return m_VDDAT; }
            set { m_VDDAT = value; }
        }
        //自定义化学转化速度文件
        private string m_CHEMDAT = "CHEM.DAT";

        public string CHEMDAT
        {
            get { return m_CHEMDAT; }
            set { m_CHEMDAT = value; }
        }

        private string m_H2O2DAT = "";

        public string H2O2DAT
        {
            get { return m_H2O2DAT; }
            set { m_H2O2DAT = value; }
        }

        //ctdm格式的次网格尺度地形文件
        private string m_HILLDAT = "";//"HILL.DAT";

        public string HILLDAT
        {
            get { return m_HILLDAT; }
            set { m_HILLDAT = value; }
        }

        //CTDM格式的次网格地形受体文件
        private string m_RCTDAT = "";

        public string RCTDAT
        {
            get { return m_RCTDAT; }
            set { m_RCTDAT = value; }
        }

        //次网格尺度的海岸边界层文件
        private string m_CSTDAT = "COASTLN.DAT";

        public string CSTDAT
        {
            get { return m_CSTDAT; }
            set { m_CSTDAT = value; }
        }

        //质量通量边界文件
        private string m_BDYDAT = "FLUXBDY.DAT";

        public string BDYDAT
        {
            get { return m_BDYDAT; }
            set { m_BDYDAT = value; }
        }

        private string m_BCNDAT = "BCON.DAT";

        public string BCNDAT
        {
            get { return m_BCNDAT; }
            set { m_BCNDAT = value; }
        }

        //烟团追踪数据文件，只在ldebug=true有效
        private string m_DEBUG = "DEBUG.DAT";

        public string DEBUG
        {
            get { return m_DEBUG; }
            set { m_DEBUG = value; }
        }

        //质量通量输出
        private string m_FLXDAT = "MASSFLX.DAT";

        public string FLXDAT
        {
            get { return m_FLXDAT; }
            set { m_FLXDAT = value; }
        }
        //质量守恒输出
        private string m_BALDAT = "MASSBAL.DAT";

        public string BALDAT
        {
            get { return m_BALDAT; }
            set { m_BALDAT = value; }
        }
        private string m_FOGDAT = "FOGDAT.dat";

        public string FOGDAT
        {
            get { return m_FOGDAT; }
            set { m_FOGDAT = value; }
        }
        private string m_RISDAT = "RISDAT.dat";

        public string RISDAT
        {
            get { return m_RISDAT; }
            set { m_RISDAT = value; }
        }

        //是否将文件名统一转换为小写
        private bool m_LCFILES = false;

        public bool LCFILES
        {
            get { return m_LCFILES; }
            set { m_LCFILES = value; }
        }

        //calmet文件个数
        private int m_NMETDAT = 1;

        public int NMETDAT
        {
            get { return m_NMETDAT; }
            set { m_NMETDAT = value; }
        }


        //对应的文件个数
        //ptemarb.
        private int m_NPTDAT = 0;

        public int NPTDAT
        {
            get { return m_NPTDAT; }
            set { m_NPTDAT = value; }
        }
        //baemarb面
        private int m_NARDAT = 0;

        public int NARDAT
        {
            get { return m_NARDAT; }
            set { m_NARDAT = value; }
        }
        //体源文件
        private int m_NVOLDAT = 0;

        public int NVOLDAT
        {
            get { return m_NVOLDAT; }
            set { m_NVOLDAT = value; }
        }





        // private string m_PathDir = "";


        public override string WriteToGroup()
        {
            string Subgroup = "", TempStr;

            TempStr = "INPUT GROUP: 0 -- Input and Output File Names\r\n";
            Subgroup += TempStr;

            TempStr = StrWriter.GetCLine();
            Subgroup += TempStr;

            if (METDAT.Count > 1 || METDAT.Count <= 0)
            {
                TempStr = "* METDAT=" + " *" + "\r\n";
            }
            else
            {
                TempStr = StrWriter.GetKeyValStr("METDAT", METDAT[0]);
            }
            Subgroup += TempStr;


            if (ISCDAT != "")
                TempStr = StrWriter.GetKeyValStr("ISCDAT", ISCDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("ISCDAT");
            Subgroup += TempStr;

            if (PLMDAT != "")
                TempStr = StrWriter.GetKeyValStr("PLMDAT", PLMDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("PLMDAT");
            Subgroup += TempStr;

            if (PRFDAT != "")
                TempStr = StrWriter.GetKeyValStr("PRFDAT", PRFDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("PRFDAT");
            Subgroup += TempStr;

            if (SFCDAT != "")
                TempStr = StrWriter.GetKeyValStr("SFCDAT", SFCDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("SFCDAT");
            Subgroup += TempStr;

            if (RSTARTB != "")
                TempStr = StrWriter.GetKeyValStr("RSTARTB", RSTARTB);
            else
                TempStr = StrWriter.GetNullKeyValStr("RSTARTB");
            Subgroup += TempStr;

            if (PUFLST != "")
                TempStr = StrWriter.GetKeyValStr("PUFLST", PUFLST);
            else
                TempStr = StrWriter.GetNullKeyValStr("PUFLST");
            Subgroup += TempStr;

            if (CONDAT != "")
                TempStr = StrWriter.GetKeyValStr("CONDAT", CONDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("CONDAT");
            Subgroup += TempStr;

            if (DFDAT != "")
                TempStr = StrWriter.GetKeyValStr("DFDAT", DFDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("DFDAT");
            Subgroup += TempStr;

            if (WFDAT != "")
                TempStr = StrWriter.GetKeyValStr("WFDAT", WFDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("WFDAT");
            Subgroup += TempStr;

            if (VISDAT != "")
                TempStr = StrWriter.GetKeyValStr("VISDAT", VISDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("VISDAT");
            Subgroup += TempStr;

            if (T2DDAT != "")
                TempStr = StrWriter.GetKeyValStr("T2DDAT", T2DDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("T2DDAT");
            Subgroup += TempStr;

            if (RHODAT != "")
                TempStr = StrWriter.GetKeyValStr("RHODAT", RHODAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("RHODAT");
            Subgroup += TempStr;

            if (RSTARTE != "")
                TempStr = StrWriter.GetKeyValStr("RSTARTE", RSTARTE);
            else
                TempStr = StrWriter.GetNullKeyValStr("RSTARTE");
            Subgroup += TempStr;

            if (PTDAT != "")
                TempStr = StrWriter.GetKeyValStr("PTDAT", PTDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("PTDAT");
            Subgroup += TempStr;

            if (VOLDAT != "")
                TempStr = StrWriter.GetKeyValStr("VOLDAT", VOLDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("VOLDAT");
            Subgroup += TempStr;

            if (ARDAT != "")
                TempStr = StrWriter.GetKeyValStr("ARDAT", ARDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("ARDAT");
            Subgroup += TempStr;

            if (LNDAT != "")
                TempStr = StrWriter.GetKeyValStr("LNDAT", LNDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("LNDAT");
            Subgroup += TempStr;

            if (OZDAT != "")
                TempStr = StrWriter.GetKeyValStr("OZDAT", OZDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("OZDAT");
            Subgroup += TempStr;

            if (VDDAT != "")
                TempStr = StrWriter.GetKeyValStr("VDDAT", VDDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("VDDAT");
            Subgroup += TempStr;

            if (CHEMDAT != "")
                TempStr = StrWriter.GetKeyValStr("CHEMDAT", CHEMDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("CHEMDAT");
            Subgroup += TempStr;

            if (H2O2DAT != "")
                TempStr = StrWriter.GetKeyValStr("H2O2DAT", H2O2DAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("H2O2DAT");
            Subgroup += TempStr;

            if (HILLDAT != "")
                TempStr = StrWriter.GetKeyValStr("HILLDAT", HILLDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("HILLDAT");
            Subgroup += TempStr;

            if (RCTDAT != "")
                TempStr = StrWriter.GetKeyValStr("RCTDAT", RCTDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("RCTDAT");
            Subgroup += TempStr;

            if (CSTDAT != "")
                TempStr = StrWriter.GetKeyValStr("CSTDAT", CSTDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("CSTDAT");
            Subgroup += TempStr;

            if (BDYDAT != "")
                TempStr = StrWriter.GetKeyValStr("BDYDAT", BDYDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("BDYDAT");
            Subgroup += TempStr;

            if (BCNDAT != "")
                TempStr = StrWriter.GetKeyValStr("BCNDAT", BCNDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("BCNDAT");
            Subgroup += TempStr;

            if (DEBUG != "")
                TempStr = StrWriter.GetKeyValStr("DEBUG", DEBUG);
            else
                TempStr = StrWriter.GetNullKeyValStr("DEBUG");
            Subgroup += TempStr;

            if (FLXDAT != "")
                TempStr = StrWriter.GetKeyValStr("FLXDAT", FLXDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("FLXDAT");
            Subgroup += TempStr;

            if (BALDAT != "")
                TempStr = StrWriter.GetKeyValStr("BALDAT", BALDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("BALDAT");
            Subgroup += TempStr;

            if (FOGDAT != "")
                TempStr = StrWriter.GetKeyValStr("FOGDAT", FOGDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("FOGDAT");
            Subgroup += TempStr;

            if (RISDAT != "")
                TempStr = StrWriter.GetKeyValStr("RISDAT", RISDAT);
            else
                TempStr = StrWriter.GetNullKeyValStr("RISDAT");
            Subgroup += TempStr;


            if (LCFILES == false)
                TempStr = "! LCFILES = " + "F !" + "\r\n";
            else
                TempStr = "! LCFILES = " + "T !" + "\r\n";
            Subgroup += TempStr;

            TempStr = "! NMETDAT = " + NMETDAT.ToString() + " !" + "\r\n";
            Subgroup += TempStr;

            TempStr = "! NPTDAT = " + NPTDAT.ToString() + " !" + "\r\n";
            Subgroup += TempStr;

            TempStr = "! NARDAT = " + NARDAT.ToString() + " !" + "\r\n";
            Subgroup += TempStr;

            TempStr = "! NVOLDAT = " + NVOLDAT.ToString() + " !" + "\r\n";
            Subgroup += TempStr;
            Subgroup += "!END!" + "\r\n";


            if (this.METDAT.Count > 1)
            {
                for (int i = 0; i < this.METDAT.Count; i++)
                {
                    if (METDAT[i] != "")
                        TempStr = StrWriter.GetKeyValStr("METDAT", METDAT[i]) + "!END!" + "\r\n";
                    else
                        TempStr = "* METDAT=" + " *" + "\r\n";
                    Subgroup += TempStr;
                }
                //Subgroup += "!END!" + "\r\n";
            }
            else
            {
                TempStr = "* METDAT=" + " *" + "\r\n";
                Subgroup += TempStr;
            }


            return Subgroup;
        }


        public override void ReadFromGroup(Dictionary<string, string> dic)
        {

            foreach (KeyValuePair<string, string> m_dic in dic)
            {
                if (m_dic.Key == "METDAT")
                {

                    this.METDAT.Add(m_dic.Value);// StrWriter.ReturnStrList(m_dic.Value);
                }
                if (m_dic.Key == "ISCDAT")
                {
                    this.ISCDAT = m_dic.Value;
                }
                if (m_dic.Key == "PLMDAT")
                {
                    this.PLMDAT = m_dic.Value;
                }
                if (m_dic.Key == "PRFDAT")
                {
                    this.PRFDAT = m_dic.Value;
                }
                if (m_dic.Key == "SFCDAT")
                {
                    this.SFCDAT = m_dic.Value;
                }
                if (m_dic.Key == "RSTARTB")
                {
                    this.RSTARTB = m_dic.Value;
                }
                if (m_dic.Key == "PUFLST")
                {
                    this.PUFLST = m_dic.Value;
                }
                if (m_dic.Key == "CONDAT")
                {
                    this.CONDAT = m_dic.Value;
                }

                if (m_dic.Key == "DFDAT")
                {
                    this.DFDAT = m_dic.Value;
                }

                if (m_dic.Key == "WFDAT")
                {
                    this.WFDAT = m_dic.Value;
                }
                if (m_dic.Key == "VISDAT")
                {
                    this.VISDAT = m_dic.Value;
                }
                if (m_dic.Key == "T2DDAT")
                {
                    this.T2DDAT = m_dic.Value;
                }
                if (m_dic.Key == "RHODAT")
                {
                    this.RHODAT = m_dic.Value;
                }
                if (m_dic.Key == "RSTARTE")
                {
                    this.RSTARTE = m_dic.Value;
                }
                if (m_dic.Key == "PTDAT")
                {
                    this.PTDAT = m_dic.Value;
                }
                if (m_dic.Key == "VOLDAT")
                {
                    this.VOLDAT = m_dic.Value;
                }
                if (m_dic.Key == "ARDAT")
                {
                    this.ARDAT = m_dic.Value;
                }
                //
                if (m_dic.Key == "LNDAT")
                {
                    this.LNDAT = m_dic.Value;
                }
                if (m_dic.Key == "OZDAT")
                {
                    this.OZDAT = m_dic.Value;
                }
                if (m_dic.Key == "VDDAT")
                {
                    this.VDDAT = m_dic.Value;
                }
                if (m_dic.Key == "CHEMDAT")
                {
                    this.CHEMDAT = m_dic.Value;
                }
                if (m_dic.Key == "H2O2DAT")
                {
                    this.H2O2DAT = m_dic.Value;
                }
                if (m_dic.Key == "HILLDAT")
                {
                    this.HILLDAT = m_dic.Value;
                }
                if (m_dic.Key == "RCTDAT")
                {
                    this.RCTDAT = m_dic.Value;
                }
                if (m_dic.Key == "CSTDAT")
                {
                    this.CSTDAT = m_dic.Value;
                }
                if (m_dic.Key == "BDYDAT")
                {
                    this.BDYDAT = m_dic.Value;
                }
                if (m_dic.Key == "BCNDAT")
                {
                    this.BCNDAT = m_dic.Value;
                }
                if (m_dic.Key == "DEBUG")
                {
                    this.DEBUG = m_dic.Value;
                }
                if (m_dic.Key == "FLXDAT")
                {
                    this.FLXDAT = m_dic.Value;
                }
                if (m_dic.Key == "BALDAT")
                {
                    this.BALDAT = m_dic.Value;
                }
                //
                if (m_dic.Key == "FOGDAT")
                {
                    this.FOGDAT = m_dic.Value;
                }
                if (m_dic.Key == "RISDAT")
                {
                    this.RISDAT = m_dic.Value;
                }
                if (m_dic.Key == "LCFILES")
                {
                    if (m_dic.Value == "T")
                    {
                        this.LCFILES = true;
                    }
                    else
                    {
                        this.LCFILES = false;
                    }

                }
                if (m_dic.Key == "NMETDAT")
                {
                    this.NMETDAT = Convert.ToInt32(m_dic.Value);
                }
                if (m_dic.Key == "NPTDAT")
                {
                    this.NPTDAT = Convert.ToInt32(m_dic.Value);
                }
                if (m_dic.Key == "NARDAT")
                {
                    this.NARDAT = Convert.ToInt32(m_dic.Value);
                }
                if (m_dic.Key == "NVOLDAT")
                {
                    this.NVOLDAT = Convert.ToInt32(m_dic.Value);
                }

            }
        }

    }
}
